﻿using Common;
using Common.DataModels;

namespace PLC.Domain.Entity;

public class BarcodeData:AggregateRoot
{
    public long DeviceId { get;  set; }
    /// <summary>
    /// 上端板码
    /// </summary>
    public string UpperEndPlateCode { get;  set; }
    /// <summary>
    /// 下端板码
    /// </summary>
    public string LowerEndPlateCode { get; set; }
    /// <summary>
    /// 膜电极码
    /// </summary>
    public string MembraneElectrode { get; set; }
    /// <summary>
    /// 双极板码
    /// </summary>
    public string BipolarPlate { get; set; }
    /// <summary>
    /// 设备类型
    /// </summary>
    public int DeviceType { get; set; }
    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreateTime { get;  set; }
    /// <summary>
    /// 是否删除
    /// </summary>
    public bool IsDelete { get;  set; }
    public BarcodeData() { }
    
    public BarcodeData SetUpperEndPlateCode(string upperEndPlateCode)
    {
        this.UpperEndPlateCode = string.IsNullOrWhiteSpace(upperEndPlateCode) ? string.Empty : upperEndPlateCode;
        return this;
    }

    public BarcodeData SetLowerEndPlateCode(string lowerEndPlateCode)
    {
        this.LowerEndPlateCode = string.IsNullOrWhiteSpace(lowerEndPlateCode)?string.Empty: lowerEndPlateCode;
        return this;
    }

    public BarcodeData SetDeviceId(long deviceId)
    {
        this.DeviceId = deviceId;
        return this;
    }
    /// <summary>
    /// 膜电极
    /// </summary>
    /// <param name="membraneElectrode"></param>
    /// <returns></returns>
    public BarcodeData SetMembraneElectrode(string membraneElectrode)
    {
        this.MembraneElectrode = string.IsNullOrWhiteSpace(membraneElectrode)?string.Empty: membraneElectrode;
        return this;
    }
    /// <summary>
    /// 双极板
    /// </summary>
    /// <param name="bipolarPlate"></param>
    /// <returns></returns>
    public BarcodeData SetBipolarPlate(string bipolarPlate)
    {
        this.BipolarPlate = string.IsNullOrWhiteSpace(bipolarPlate) ? string.Empty : bipolarPlate;
        return this;
    }

    public BarcodeData SetIsDelete(bool isDelete)
    {
        this.IsDelete = isDelete;
        return this;
    }
    public BarcodeData  Build()
    {
        base.Id = SnowflakeHelper.GetId();
        this.IsDelete = false;
        this.CreateTime = DateTime.Now;
        return this;
    }
}